<?php

namespace Trawind\Remotes\Repositories\Product\Item;

use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\BaseRepository;
use Trawind\Remotes\Contracts\Repositories\Product\Item\SpuRepository;

/**
 * Class UnitsRepositoryEloquent.
 *
 * @package namespace TrawindCloud\Repositories\Product\Item;
 */
class SpuRepositoryEloquent extends BaseRepository implements SpuRepository
{

   public $baseRoute='/item/spus';

    public function __construct()
    {
        $this->domain=ServiceDomain::PRODUCT_DOMAIN();
    }

    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }

    public function find($id, $columns = ['*'])
    {
        return $this->setUrl($this->baseRoute.'/'.$id)->result();
    }

    public function create(array $attributes)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => $attributes])
            ->result('POST');
    }

    public function update(array $attributes, $id)
    {
        return $this->setUrl($this->baseRoute.'/'.$id)
            ->setClientOptions(['form_params' => $attributes])
            ->result('PUT');
    }


}
